<?php
session_start();
include '../../include/dbFunctions.php';

if (isset($_SESSION['rep_id'])) {
    $rep_id = $_SESSION['rep_id'];

$valid = "true";

$email = trim(strtolower($_REQUEST['contact_email']));

$query = executeSelectQuery("SELECT contact_email FROM contact_school WHERE contact_email = '" . $email . "' AND contact_school_id <> $rep_id;");

if (count($query) > 0) {
    $valid = "false"; //Email is existed, cannot use
}
echo $valid;

}


/* For Debugging
  $query = "SELECT * FROM username WHERE email = '" . $email . "';";
  foreach ($dbh->query($query) as $row) {
  echo $row['email'] . "<br/>";
  }
 */
?>
